import axios from 'axios'
import {Modal} from 'iview'
import store from './store/store'
var instance = axios.create({//axios的全局配置-
  //baseURL: 'http://localhost:14143/api/',//全局变量--请求地址//http://localhost:7453/api/&&http://115.29.104.243:63333/api/
  //baseURL:'http://115.29.104.243:63338/api/',
  baseURL:'http://120.77.69.221:8107/api/',
  //headers: {'X-Requested-With': 'XMLHttpRequest'},//请求头
  withCredentials: true,
});
instance.interceptors.request.use(config=>{
    //loading动画打开
    store.dispatch('loadingShow');
    return config
},function(error){
    console.log(error);
    //loading动画关闭
    store.dispatch('loadingHide');
    return Promise.reject(error);
})
instance.interceptors.response.use(response=>{
    //loading动画关闭
    store.dispatch('loadingHide');
    return response
},function(error){
    //异常提示
    Modal.warning({ title: "提示信息", content: "网络异常,请稍后重试!!!" }); 
    console.log(error);
    //loading动画关闭
    store.dispatch('loadingHide');
    return Promise.reject(error);
})

export default instance